#include <iostream>
#include <ctime>
#include "ThreadPool.hpp"
#include "Task.hpp"

int main()
{
    std::cout<<"Process running..."<<std::endl;
    ThreadPool<Task>::GetInstance()->Start();   //线程已准备，等待着任务

    srand(getpid()^time(nullptr));
    while(true)
    {
        //创建任务
        int a=rand()%10;
        int b=rand()%10;
        int len=opers.size();
        char oper=opers[rand()%len];
        usleep(10);
        Task t(a,b,oper);
        std::cout<<"main thread make task: "<<t.GetTask()<<std::endl;

        //放入线程池中，线程池会自动处理任务，因为线程已开启，并且一直在循环，不会退出
        ThreadPool<Task>::GetInstance()->PushTask(t);
        sleep(1);
    }

    ThreadPool<Task>::GetInstance()->Destroy();

    return 0;
}
